import { ENV_CONFIG } from './env';

// 获取当前环境
const currentEnv = import.meta.env.MODE || 'production';

// 获取环境配置
const envConfig = ENV_CONFIG[currentEnv];

// 环境配置
const config = {
  // API 基础URL
  apiBaseUrl: envConfig.API_BASE_URL,
  // WebRTC URL
  webrtcUrl: envConfig.WEBRTC_URL,
  // 环境
  env: envConfig.APP_ENV,
  // 流地址
  rtmpUrl: envConfig.RTMP_URL,
  httpFlvUrl: envConfig.HTTP_FLV_URL,
  hlsUrl: envConfig.HLS_URL,
  hlsUrlOriginal: envConfig.HLS_URL_ORIGINAL,
  httpFlvUrlOriginal: envConfig.HTTP_FLV_URL_ORIGINAL,
  rtmpUrlOriginal: envConfig.RTMP_URL_ORIGINAL,
  
  // WebRTC 配置
  rtcConfig: {
    // 推流API
    publishApi: '/v1/publish',
    // ICE服务器配置
    iceServers: [
      {
        urls: 'stun:stun.l.google.com:19302'
      }
    ]
  }
};

// 获取完整的API URL
export const getApiUrl = (path) => {
  return `${config.apiBaseUrl}${path}`;
};

// 获取WebRTC URL
export const getWebrtcUrl = () => {
  return config.webrtcUrl;
};

// 获取推流URL
export const getPublishUrl = () => {
  return getApiUrl(config.rtcConfig.publishApi);
};

// 获取ICE服务器配置
export const getIceServers = () => {
  return config.rtcConfig.iceServers;
};

// 获取RTMP URL
export const getRtmpUrl = () => {
  return config.rtmpUrl;
};

// 获取HTTP-FLV URL
export const getHttpFlvUrl = () => {
  return config.httpFlvUrl;
};

// 获取HLS URL
export const getHlsUrl = () => {
  return config.hlsUrl;
};


// 获取HLS URL 直接地址
export const getHlsUrlOriginal = () => {
  return config.hlsUrlOriginal;
};

// 获取HTTP-FLV URL 直接地址
export const getHttpFlvUrlOriginal = () => {
  return config.httpFlvUrlOriginal;
};

// 获取RTMP URL 直接地址
export const getRtmpUrlOriginal = () => {
  return config.rtmpUrlOriginal;
};




// 是否是开发环境
export const isDev = () => {
  return config.env === 'development';
};

export default config; 